﻿using System;
using System.Collections.Generic;
using System.Text;
using BarCode.Bean;
using BarCode.Common;
using System.Data;
using BarCode.Module;
using MySql.Data.MySqlClient;

namespace BarCode.AccessDao
{
    public class DB05Dao
    {
        private static readonly log4net.ILog LogUtil = log4net.LogManager.GetLogger(typeof(DB05Dao));

        private MySqlHelper db05;
        public DB05Dao(string serverIp, string userId, string userPwd)
        {
            db05 = new MySqlHelper(serverIp, "db_05", userId, userPwd);
        }

        /// <summary>
        /// 判断是否可链接
        /// </summary>
        /// <returns></returns>
        public bool EnableConnect()
        {
            return db05.EnableConnect();
        }

        /// <summary>
        /// 根据二维码获取批号
        /// </summary>
        /// <returns></returns>
        public string getListId(string barcode)
        {
            MySqlParameter sqlParam = new MySqlParameter("@pbatchid", barcode);
            DataSet retSet = db05.GetDataSet(CommandType.Text, "select listid from tblpartboxin where pbatchid=@pbatchid", new MySqlParameter[] { sqlParam });
            if (retSet != null && retSet.Tables.Count > 0)
            {
                DataTable dt = retSet.Tables[0];
                if (dt.Rows.Count > 0)
                {
                    return Convert.ToString(dt.Rows[0][0]);
                }
            }
            return "";
        }


    }
}
